<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('招聘信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input id="roleId" th:value="${roleId}" type="hidden">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>招聘岗位：</label>
                                <input type="text" name="recruitmentName"/>
                            </li>
                            <li id="ifShow">
                                <label>招聘公司：</label>
                                <input type="text" name="recruitmentCompany"/>
                            </li>
                            <li>
                                <label>薪资：</label>
                                <input type="text" name="recruitmentSalary"/>
                            </li>
                            <li>
                                <label>招聘状态：</label>
                                <input type="text" name="recruimentStatic"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:recruitment:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:recruitment:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:recruitment:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var giveResume = [[${@permission.hasPermi('system:recruitment:giveResume')}]];
        var detail = [[${@permission.hasPermi('system:recruitment:detail')}]];
        var editFlag = [[${@permission.hasPermi('system:recruitment:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:recruitment:remove')}]];
        var prefix = ctx + "system/recruitment";

        $(function() {
            var roleId = $("#roleId").val();
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "招聘信息",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'recruitmentId',
                    title: '招聘信息id',
                    visible: false,

                },
                {
                    field: 'recruitmentName',
                    title: '招聘岗位名称'
                },
                {
                    field: 'recruitmentCompany',
                    title: '招聘公司'
                },
                {
                    field: 'recruitmentDemand',
                    title: '招聘要求'
                },
                {
                    field: 'recruitmentSalary',
                    title: '薪资'
                },
                {
                    field: 'recruimentStatic',
                    title: '招聘状态'
                },
                {
                    field: 'remark',
                    title: '备注',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        //如果是应聘者，添加投递简历按钮
                        if (roleId == 4) {
                            actions.push('<a class="btn btn-success btn-xs ' + detail + '" href="javascript:void(0)" onclick="getDetail(\'' + row.recruitmentId + '\')"><i class="fa fa-remove"></i>详情</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + giveResume + '" href="javascript:void(0)" onclick="giveRecruitment(\'' + row.recruitmentId + '\')"><i class="fa fa-edit"></i>投递简历</a> ');
                        }
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.recruitmentId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }],
            };
            $.table.init(options);

            //如果角色是公司，则不需要搜索公司名称
            if (roleId == 3) {
                $("#ifShow").hide();
            }
        });

        //发送简历接口
        function giveRecruitment(recruitmentId) {
            $.modal.open('选择简历', prefix + '/choseResume/' + recruitmentId, '600', '300');
        }

        //查看招聘信息详情
        function getDetail(recruitmentId) {
            $.modal.open('招聘信息详情', prefix + '/detail/' + recruitmentId, '900', '600');
        }
    </script>
</body>
</html>
